<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html  style="height:200px;">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	<title>物业管理系统</title>
    <base href="<%=basePath%>"> 
		<link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/vivo.css">
    <link rel="stylesheet" href="css/cmxform.css">
    <link rel="stylesheet" href="js/grid/bsgrid.all.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="js/Hui-iconfont/1.0.7/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="js/icheck/icheck.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<link rel="stylesheet" href="js/grid/bsgrid.all.min.css"/>
	<style type="text/css">
			.primary-vdd {
			color: #fff;
			background-color: #5a98de;
			border-color: #5a98de
			}

			.primary-vdd:hover
				{
				color: #fff;
				background-color: #0a6999;
				border-color: #0a6999
			}
			#watchType:hover{
				border-color:#CCCCCC;
				
			}
		</style>
	<script src="js/jquery-1.11.1.js"></script>
    <script src="js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
    <script src="js/jquery.validation/1.14.0/messages_zh.min.js"></script>
    <script type="text/javascript" src="js/layer/layer/layer.js"></script> 
    <script type="text/javascript" src="js/sharefunction.js"></script>
    <script language="javascript" type="text/javascript"
			src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript">
		
		$.validator.setDefaults({
		    submitHandler: function() {
		      	saveDocument();
		    }
		});
		
		$(document).ready(function() {
			var i="${roomWatch.watchType}";
			if(i==2){
				$("#watchType").val("电表");
				$("#watchType1").val("2");
			}else if(i==1){
				$("#watchType").val("热水表");
				$("#watchType1").val("1");
			}else{
				$("#watchType").val("冷水表");
				$("#watchType1").val("0");
			}
		    $("#commentForm").validate({
		    	errorPlacement: function(error, element) {
					// Append error within linked label
					$( element ).next().append( error );
				},
				errorElement: "span",
				rules: {
					reading:{
					maxlength: 9,
					max:999999,
					min:0
					},
					readTime:{
					min:$("#time").val()
					}
				},
				messages: {
					typeName: {
						required: " 必需字段!",
						minlength: " (不能少于 3 个字母)"
					},
					watchNo:{
					number:"请输入合法编号！ "
				},
				reading:{
					maxlength:"输入的数字超范围",
					min:"输入的数字超范围",
					max:"输入的数字超范围",
					number:"请输入合法数字! "
				},
				readTime:{
					min:"读数日期必须大于上次读数日期("+$('#time').val()+")"
				},
				watchName:{
					required:"请输入表具名称！"
				}
			}
				
		    });
		});
		
		function saveDocument(){
			var watchType=$("#watchType1").val();
			var watchName=$("#watchName").val();
			var watchNo=$("#watchNo").val();
			var reading=$("#reading").val();
			var readTime=$("#readTime").val();
			var watchid=$("#roomWatchId").val();
			var roomId=$("#roomId").val();
			//layer.confirm("确定保存吗？",{icon:3},function(i){
				var url="room/roomWatch/update";
				jQuery.ajax({
				    type:"post",
				    async:false,
				    url:url,
			        dataType:"json",
			        data:{
				        watchType:watchType,
				        roomId:roomId,
				        watchName:watchName,
				        watchNo:watchNo,
				        reading:reading,
				        readTime:readTime,
				        id:watchid
				        },
				    success:function(data){
							            if(data.success){
			        		 						window.parent.gridObj.refreshPage();
			        		 						window.parent.gridObj4.refreshPage();
			        		 						window.parent.layer.msg('保存成功！');
			        		 						closeLayer(); 
							            		
							   	        }else{
							            	layer.alert(data.msg,{icon:7});
							            }
							        }
		   		});
			//});
		}
	</script>
	
	</head>
	<body>
		<form class="cmxform" id="commentForm" method="get" action="">
		<div class="panel panel-default" style="margin:20px ;">
			<div class="panel-heading">
      				<h5 class="panel-title">基本信息</h5>
   			  	</div>
	   			<div class="panel-body">
			<table cellpadding="10" cellspacing="5" class="mytable">
				<tr>
					<td width="90">类别</td>
					<td width="250">
						<input type="hidden" id="watchType1" readonly="readonly" style="border-color:#CCCCCC " />
						<input type="text" id="watchType" readonly="readonly" style="border-color:#CCCCCC " />
					</td>		
				</tr>		
				<tr>
					<td width="90">表具名称</td>
					<td><input type="text" name="watchName" id="watchName" required value="${roomWatch.watchName}"/><font color="red"> *</font><span style="color:red"></span> </td>
					
					<td width="90">表具编号</td>
					<td>
						<input type="text" name="watchNo" id="watchNo" class="number" value="${roomWatch.watchNo}" >
						<input type="hidden" name="roomWatchId" id="roomWatchId" value="${roomWatch.id}">
					</td>
				</tr>
				<tr>
					<td width="90">最新读数</td>
					<td><input type="text" name="reading" id="reading" class="number" style="border-color:#CCCCCC " value="${roomWatch.reading}"  readonly="readonly"/> </td>
					<td width="90">读数日期</td>
					<td>
						<input type="text" name="readTime" id="readTime" style="border-color:#CCCCCC "
						readonly="readonly" value="${roomWatch.readTime}"/><span style="color:red"></span>
						<input type="hidden" name="time" id="time" value="${fee.currentReadingDate}">
					</td>
					<td></td>
				</tr>
			</table>
			</div>
			</div>
			<div style="width:100%;text-align:center; padding-top:20px"> 
				<button class="btn btn-primary radius primary-vdd" type="submit" > 保 存</button> 
				 <a class="btn btn-default radius" onClick="closeLayer();"> 取 消 </a> 
		    	  <br/><br/>
	    	</div> 
	    	 
		
		
		<input id="typeChoice" name="typeChoice" type="hidden" value="${typeChoice}"/>
		<input id="roomId" name="roomId" type="hidden" value="${roomId}"/>
		</form>
  	</body>
  	
   </html>
  	
